package com.itheima.inetaddress;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Demo01 {
    public static void main(String[] args) throws UnknownHostException {
        //创建ip对象
        //InetAddress address = InetAddress.getByName("徐谱盛");
        InetAddress address = InetAddress.getByName("192.168.23.1");

        //得到设备的主机名
        String hostName = address.getHostName();
        System.out.println("主机名为:"+hostName);

        //得到设备的ip地址
        String hostAddress = address.getHostAddress();
        System.out.println("主机的ip地址为:"+hostAddress);
    }
}
